package hu.elte.inf.holiuml.model;

import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
import java.util.Vector;

import javax.smartcardio.ATR;

/**
 * @author Csaba Hoch
 */
public class ClassNode extends Node {

	private UMLClass umlClass = null;
	private boolean visibleAttributes = false;
	private boolean visibleOperations = false;

	public ClassNode(ClassNode classNode) {
		this.umlClass = new UMLClass(classNode.getUMLClass());
		this.visibleAttributes = new Boolean(classNode.getVisibleAttributes());
		this.visibleOperations = new Boolean(classNode.getVisibleOperations());
	}
	public ClassNode() {
	}

	/**
	 * The lines will contain the name of the class, the attributes if they are
	 * visible, and the operations if they are visible.
	 */
	@Override
	protected void recalculateLines(Graphics g) {
		lines.add(umlClass.getName());
		if (visibleAttributes) {
			lines.add(null);
			for (Attribute attr : umlClass.getAttributes()) {
				lines.add(attr.toString());
			}
		}
		if (visibleOperations) {
			lines.add(null);
			for (Operation op : umlClass.getOperations()) {
				lines.add(op.toString());
			}
		}
	}

	public void setUMLClass(UMLClass umlClass) {
		this.umlClass = umlClass;
		sizeUpToDate = false;
	}

	public UMLClass getUMLClass() {
		return umlClass;
	}

	public void setVisibleAttributes(boolean visible) {
		this.visibleAttributes = visible;
		sizeUpToDate = false;
	}

	public boolean getVisibleAttributes() {
		return visibleAttributes;
	}

	public void setVisibleOperations(boolean visible) {
		this.visibleOperations = visible;
		sizeUpToDate = false;
	}

	public boolean getVisibleOperations() {
		return visibleOperations;
	}
}
